package com.aaa.controller;

import com.aaa.entity.Discuss;
import com.aaa.service.DiscussService;
import com.aaa.util.DefaultMsg;
import org.springframework.security.core.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Discuss")
public class DiscussController {

    @Autowired
    private DiscussService discussService;

    @RequestMapping("/ListDiscuss")
    public List<Discuss> ListDiscuss(String mid, Authentication authentication){
        String principal = (String) authentication.getPrincipal();
        List<Discuss> discuss = discussService.discuss(mid, principal);
        return discuss;
    }

    @RequestMapping("/discuessMe")
    public DefaultMsg discuessMe(Discuss discuss,Authentication authentication){
        String principal = (String) authentication.getPrincipal();
        discuss.setLid(principal);
        DefaultMsg defaultMsg = discussService.discuessMe(discuss);
        return defaultMsg;
    }
}
